package com.example.test_activity.utils;

import android.util.Log;

import com.example.test_activity.http.HttpUtil;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;

/**
 * Created by 旭 on 2017/3/27/027.
 */

public class GetUser {

    String user;

    public String getUser() {

        try {
            String html = HttpUtil.getInstance().sendGetPost().getUser().execute().body().string();
            user(html);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return this.user;
    }

    //获取学生姓名和学号数据
    private void user(String html)
    {
            Document document = Jsoup.parse(html);
            Elements elements = document.select("[nowrap= ]");
            Element element = elements.get(0);
            String temp = element.text();
            temp = temp.substring(7, 24);
            this.user = temp.substring(0, 16);
    }
}
